#define _CRT_SECURE_NO_WARNINGS

#include "BinaryTree.h"

BTNode* BTCreateNode(BTDataType data)
{
	BTNode* temp = malloc(sizeof(BTNode));
	if (!temp)
	{
		printf("Malloc failed.\n");
		exit(1);
	}
	temp->data = data;
	temp->left = temp->right = NULL;
	return temp;
}

void BTPreOrder(BTNode* root)
{
	if (!root)
	{
		printf("NULL ");
		return;
	}
	printf("%c ", root->data);
	BTPreOrder(root->left);
	BTPreOrder(root->right);
}

void BTInOrder(BTNode* root)
{
	if (!root)
	{
		printf("NULL ");
		return;
	}
	BTInOrder(root->left);
	printf("%c ", root->data);
	BTInOrder(root->right);
}

void BTPostOrder(BTNode* root)
{
	if (!root)
	{
		printf("NULL ");
		return;
	}
	BTPostOrder(root->left);
	BTPostOrder(root->right);
	printf("%c ", root->data);
}